Skip to content

ref(node): Use Sentry span APIs in vendored connect instrumentation#21529

Merged
nicohrubec merged 2 commits into
nh/streamline-connectfrom
nh/sentryfy-connect
Jun 15, 2026
Merged

ref(node): Use Sentry span APIs in vendored connect instrumentation#21529
nicohrubec merged 2 commits into
nh/streamline-connectfrom
nh/sentryfy-connect

Conversation

@nicohrubec

Copy link
Copy Markdown
Member

Stacked on top of #21404.

Migrates the vendored connect instrumentation off the OTel tracer/context APIs to startInactiveSpan from @sentry/core (the faithful fit for connect's create-now / end-on-next()-or-res-close, non-active span lifecycle), and replaces the last @opentelemetry/api runtime usage (diag.warn) with the Sentry debug logger.

Also marks middleware spans as internal_error when the middleware errors — either by throwing (caught around the middleware invocation) or by calling next(err). This is a small behavior improvement over upstream OTel connect (which never set status), consistent with the generic-pool and fastify/nestjs instrumentations. Adds an assertion that the /error request_handler span is internal_error.

Replace the OTel tracer/context span lifecycle with `startInactiveSpan` from
`@sentry/core`, and mark middleware spans as errored (throw or `next(err)`).
Swap the remaining `diag.warn` for the Sentry debug logger.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.2 kB added added
@sentry/browser - with treeshaking flags 25.65 kB added added
@sentry/browser (incl. Tracing) 45.5 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 47.73 kB added added
@sentry/browser (incl. Tracing, Profiling) 50.28 kB added added
@sentry/browser (incl. Tracing, Replay) 84.71 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.33 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 89.4 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 102.1 kB added added
@sentry/browser (incl. Feedback) 44.36 kB added added
@sentry/browser (incl. sendFeedback) 32.02 kB added added
@sentry/browser (incl. FeedbackAsync) 37.11 kB added added
@sentry/browser (incl. Metrics) 28.27 kB added added
@sentry/browser (incl. Logs) 28.51 kB added added
@sentry/browser (incl. Metrics & Logs) 29.22 kB added added
@sentry/react 29.02 kB added added
@sentry/react (incl. Tracing) 47.77 kB added added
@sentry/vue 32.22 kB added added
@sentry/vue (incl. Tracing) 47.4 kB added added
@sentry/svelte 27.23 kB added added
CDN Bundle 29.57 kB added added
CDN Bundle (incl. Tracing) 47.95 kB added added
CDN Bundle (incl. Logs, Metrics) 31.08 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 49.19 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 70.36 kB added added
CDN Bundle (incl. Tracing, Replay) 85.33 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.51 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 91.15 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.33 kB added added
CDN Bundle - uncompressed 87.7 kB added added
CDN Bundle (incl. Tracing) - uncompressed 144.9 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 92.19 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.65 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 217 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 263.76 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 267.51 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.46 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.2 kB added added
@sentry/nextjs (client) 50.26 kB added added
@sentry/sveltekit (client) 45.92 kB added added
@sentry/core/server 75.94 kB added added
@sentry/core/browser 63.09 kB added added
@sentry/node-core 61.7 kB added added
@sentry/node 130.39 kB added added
@sentry/node - without tracing 74.06 kB added added
@sentry/aws-serverless 86.26 kB added added
@sentry/cloudflare (withSentry) - minified 173.59 kB added added
@sentry/cloudflare (withSentry) 433.61 kB added added

Move the Sentry op/origin/name off the `addConnectSpanAttributes` spanStart
hook into the `startInactiveSpan` call, so they're set unconditionally (the
hook only ran when `setupConnectErrorHandler` was used). Drop the now-unused
`ConnectNames` enum and the hook.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec nicohrubec merged commit be87fa5 into nh/streamline-connect Jun 15, 2026
8 checks passed
@nicohrubec nicohrubec deleted the nh/sentryfy-connect branch June 15, 2026 11:22
@nicohrubec

Copy link
Copy Markdown
Member Author

Folded into #21404 via fast-forward merge into nh/streamline-connect — GitHub auto-marked this as merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant